#include "Button.h"

Button::Button(void) 
{ 
	
}

Button::Button(const char* strName, int btnId, int texId, float left, float top, float width, float height):
isHovered(false)
{
	m_iID = btnId;
	m_strName = new char[strlen(strName)+1];
	strcpy(m_strName, strName);
	m_BoundingBox.left = left;
	m_BoundingBox.right = left + width;
	m_BoundingBox.bottom = top + height;
	m_BoundingBox.top = top;
	m_sprImage = new CSprite();
	m_sprImage->SetTexture(texId);
}

Button::~Button(void)
{
	SAFE_ARRAY_DEL(m_strName);	
	SAFE_DEL(m_sprImage);

}

void Button::Update(float dt)
{
	
}

void Button::Render()
{
	CRect texCoord;
	if(!isHovered)
	{
		texCoord = CRect(0, 0, 1, 0.5);
	} else
	{
		texCoord = CRect(0, 0.5, 1, 1);
	}
		
	m_sprImage->Render(&m_BoundingBox, &texCoord);
}

bool Button::ContainMousePoint(float x, float y)
{
	return m_BoundingBox.ContainPoint(x, y);
}

